import json
import mysql.connector
import collections

conn = mysql.connector.connect(user="root",password="",database="mytest")
# self.mysql_cur = self.mysql_conn.cursor()
cursor = conn.cursor()

cursor = conn.cursor()
cursor.execute('''select time,value from ecg''')
values = cursor.fetchall()
rowarray_list = []
for row in values:
	d = collections.OrderedDict()
	d['label'] = row[0]
	d['value'] = row[1]
	rowarray_list.append(d)
 
j = json.dumps(rowarray_list)
rowarrays_file = 'ecg1.js'
f = open(rowarrays_file,'w')
print >> f, j